package com.xingu.xg.converter;

import com.xingu.xg.domain.dto.TreeNodeDto;
import com.xingu.xg.domain.entity.TreeNode;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import java.util.List;

@Mapper
public interface TreeNodeConverter {

    TreeNodeConverter INSTANCE = Mappers.getMapper(TreeNodeConverter.class);

    @Mapping(target = "isLeaf", constant = "true")
    @Mapping(target = "children", expression = "java( new ArrayList<TreeNodeDto>() )")
    TreeNodeDto toDto(TreeNode src);

    List<TreeNodeDto> toDto(List<TreeNode> src);

    TreeNode toEntity(TreeNodeDto src);
}
